<?php

/* developer    : BREEZEER
 * date         : 2022.04.13
 * description  :
 *              1. 招标采购管理包括不限于添加，删除，修改，审批
 */
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\modelTenderBidding\mTenderBidding;
use App\Models\modelTenderBidding\mTenderBiddingSupplierName;
use App\Models\modelTenderBidding\mTenderBiddingClarify;
use App\Models\modelTenderBidding\mTenderBiddingBusinessRequirementsPaymentStage;
use App\Models\modelTenderBidding\mTenderBiddingBiddingAnnouncementDocuments;
use App\Func\AuthFunc;
use App\Func\TokenFuc;

class tender_purchase extends Controller
{
    public function __construct(){
        
        #
        #
        $this->m_o_cHelper											= app()->gcHelper										;
        $this->m_cHelper											= $this->m_o_cHelper									;
        $this->m_o_mTenderBidding                                   = new mTenderBidding()                                  ; # model : mTenderBidding                                  => 招标采购
        $this->m_o_mTenderBiddingSupplierName                       = new mTenderBiddingSupplierName                        ; # model : mTenderBiddingSupplierName                      => 招标采购_供应商名称
        $this->m_o_mTenderBiddingClarify                            = new mTenderBiddingClarify                             ; # model : mTenderBiddingClarify                           => 招标采购澄清说明
        $this->m_o_mTenderBiddingBusinessRequirementsPaymentStage   = new mTenderBiddingBusinessRequirementsPaymentStage    ; # model : mTenderBiddingBusinessRequirementsPaymentStage  => 招标采购_商务要求_付款方式_阶段
        $this->m_o_mTenderBiddingBiddingAnnouncementDocuments       = new mTenderBiddingBiddingAnnouncementDocuments        ; # model : mTenderBiddingBiddingAnnouncementDocuments      => 招标采购_招标公告文件
    }
    
    /* 从路由获取 dispatch_cmd_id 自动调用类的不同方法
     * 
     *
     */
    public function ini($dispatch_cmd_id)
    {
       return $this->m_o_cHelper->gfDispatchCommandIdToClassMethod		(

																			$this   
																			,
																			@array  (
																						'1'     => 'applyTenderPurchaseAdd'										,
																						'2'     => 'applyTenderPurchaseGetAllList'								,
																						'100'   => 'applyTenderPurchaseModfiy'									,
																						'200'   => 'participateInBiddingSupplierInformationAdd'					,
																						'201'   => 'participateInBiddingSupplierInformationGetAllList'			,
																						'300'   => 'tenderBiddingClarifyAdd'									,
																						'301'   => 'tenderBiddingClarifyGetAllList'								,
																						'400'   => 'tenderBiddingBiddingAnnouncementDocumentsAdd'				,
																						'401'   => 'tenderBiddingBiddingAnnouncementDocumentsGetAllList'		,
																						'500'   => 'tenderBiddingBusinessRequirementsPaymentStageAdd'			,
																						'501'   => 'tenderBiddingBusinessRequirementsPaymentStageGetAllList'	,
																					) [$dispatch_cmd_id]
																		);
    }

    /* title            : 招标公告文件全部列表
     * date             : 2022.04.18
     * description      :
     *
     */
    public function tenderBiddingBiddingAnnouncementDocumentsGetAllList()
    {
       
        return  $this->m_o_cHelper->gfJsonDecode       (
                                                            request()->get('tender_bidding_bidding_announcement_documents_get_all_list','{}'),
                                                            function($j) 
															{
                                                                $j->setDecodeStatus($this->m_o_mTenderBiddingBiddingAnnouncementDocuments->getQueryAllListData($j,$this->m_o_cHelper),'401.1000',"招标公告文件全部列表成功");
                                                            }
															,
                                                            function($j) 
															{
                                                                $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'401.2000','招标公告文件全部列表失败');
                                                            }
                                                        )->getDecodeStatus();
    }

    /* title            : 商务要求付款方式的阶段全部列表
     * date             : 2022.04.18
     * description      :
     *
     */
    public function tenderBiddingBusinessRequirementsPaymentStageGetAllList()
    {
       
        return  $this->m_o_cHelper->gfJsonDecode     (
                                                    request()->get('tender_bidding_business_requirements_payment_stage_get_all_list','{}'),
                                                    function($j) {

                                                        $j->setDecodeStatus($this->m_o_mTenderBiddingBusinessRequirementsPaymentStage->getQueryAllListData($j,$this->m_o_cHelper),'501.1000',"商务要求付款方式的阶段全部列表成功");
                                                    },
                                                    function($j) {

                                                        $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'501.2000','商务要求付款方式的阶段全部列表失败');
                                                    }
                                                )->getDecodeStatus();
    }

    /* title            : 招标采购澄清说明全部列表
     * date             : 2022.04.18
     * description      :
     *
     */
    public function tenderBiddingClarifyGetAllList()
    {
       
        return  $this->m_o_cHelper->gfJsonDecode     (
                                                            request()->get('tender_bidding_clarify_get_all_list','{}'),
                                                            function($j) {

                                                                $j->setDecodeStatus($this->m_o_mTenderBiddingClarify->getQueryAllListData($j,$this->m_o_cHelper),'301.1000',"招标采购澄清说明全部列表成功");
                                                            },
                                                            function($j) {

                                                                $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'301.2000','招标采购澄清说明全部列表失败');
                                                            }
                                                        )->getDecodeStatus();
    }

    /* title            : 参与投标供应商资料全部列表
     * date             : 2022.04.18
     * description      :
     *
     */
    public function participateInBiddingSupplierInformationGetAllList()
    {
       
        return  $this->m_o_cHelper->gfJsonDecode     (
                                                            request()->get('participate_in_bidding_supplier_information_get_all_list','{}'),
                                                            function($j) {

                                                                $j->setDecodeStatus($this->m_o_mTenderBiddingSupplierName->getQueryAllListData($j,$this->m_o_cHelper),'201.1000',"参与投标供应商资料全部列表成功");
                                                            },
                                                            function($j) {

                                                                $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'201.2000','参与投标供应商资料全部列表失败');
                                                            }
                                                        )->getDecodeStatus();
    }

    /* title            : 获取招标采购的全部列表
     * date             : 2022.04.15
     * description      :
     *
     */
    public function applyTenderPurchaseGetAllList(){
       
        return  $this->m_o_cHelper->gfJsonDecode   (
                                                            request()->get('apply_tender_purchase_get_all_list','{}'),
                                                            function($j) {

                                                                $j->setDecodeStatus($this->m_o_mTenderBidding->getQueryAllListData($j,$this->m_o_cHelper),'2.1000','获取招标采购的全部列表成功');
                                                            },
                                                            function($j) {

                                                                $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'2.2000','获取招标采购的全部列表失败');
                                                            }
                                                        )->getDecodeStatus();
    }

    /* title            : 商务要求付款方式的阶段添加
     * date             : 2022.04.15 
     * description      : 
     *
     * 
     */
    public function tenderBiddingBusinessRequirementsPaymentStageAdd(){

      return  $this->m_o_cHelper->gfJsonDecode   (
                                                request()->get('tender_bidding_business_requirements_payment_stage_add','{}'),
                                                function($j) {

                                                    $j->setDecodeStatus($this->m_o_mTenderBiddingBusinessRequirementsPaymentStage->add($j,$this->m_o_cHelper),'500.1000','商务要求付款方式的阶段添加成功');
                                                },
                                                function($j) {

                                                    $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'500.2000','商务要求付款方式的阶段添加失败');
                                                }
                                            )->getDecodeStatus();

    } 

    /* title            : 招标采购_招标公告文件添加
     * date             : 2022.04.15 
     * description      :
     *
     */ 
    public function tenderBiddingBiddingAnnouncementDocumentsAdd(){

        return  $this->m_o_cHelper->gfJsonDecode     (
                                                    request()->get('tender_bidding_bidding_announcement_documents_add','{}'),
                                                    function($j) {

                                                        $j->setDecodeStatus($this->m_o_mTenderBiddingBiddingAnnouncementDocuments->add($j,$this->m_o_cHelper),'400.1000',"招标采购_招标公告文件添加成功");
                                                    },
                                                    function($j) {

                                                        $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'400.2000','招标采购_招标公告文件添加失败');
                                                    }
                                                )->getDecodeStatus();

    } 
    /* title            : 招标采购澄清说明添加
     * date             : 2022.04.15 
     * description      :
     *
     */ 
    public function tenderBiddingClarifyAdd(){

        return  $this->m_o_cHelper->gfJsonDecode     (
														request()->get('tender_bidding_clarify_add','{}'),
														function($j) {

															$j->setDecodeStatus($this->m_o_mTenderBiddingClarify->add($j,$this->m_o_cHelper),'300.1000',"招标采购澄清说明添加成功");
														},
														function($j) {

															$j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'300.2000','招标采购澄清说明添加失败');
														}
													)->getDecodeStatus();
        
    } 
    
    /* title            : 参与投标供应商资料添加
     * date             : 2022.04.15 
     * description      :
     * 
     *  
     */
	public function	tenderBiddingSupplierInformationCreate		(){ return $this->participateInBiddingSupplierInformationAdd();}
    public function participateInBiddingSupplierInformationAdd	(){
        
       
		return $this->m_cHelper->gfApiEchoEx	(
													$this->m_o_cHelper->gfJsonDecode     (

																	$this->m_cHelper->gfGetRequestBodyValue(),
																	function($j) {

																		$j->setDecodeStatus($this->m_o_mTenderBiddingSupplierName->add($j,$this->m_o_cHelper),'tenderBiddingSupplierInformationCreate.1000',"参与投标供应商资料添加"."成功");
																	},
																	function($j) {

																		$j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'tenderBiddingSupplierInformationCreate.2000','参与投标供应商资料添加'.'失败');
																	}
													)->getDecodeStatus()
												);

    }
    public function applyTenderPurchaseModfiy()
    {
        return array('applyTenderPurchaseModfiy.ok');
    }

    /* title            : 招标采购添加
     * date             : 2022.04.15
     * description      :
	 *
	 *
	 *
	 *
     */
	public function tenderBiddingCreate		(){ return $this->applyTenderPurchaseAdd();}
    public function applyTenderPurchaseAdd	(){
        
        return  $this->m_cHelper->gfApiEchoEx	(
													$this->m_o_cHelper->gfJsonDecode     (

                                                            $this->m_cHelper->gfGetRequestBodyValue(),
                                                            function($j) {

                                                                $j->setDecodeStatus($this->m_o_mTenderBidding->add($j,$this->m_o_cHelper),'applyTenderPurchaseAdd.1000',"招标采购添加"."成功");
                                                            },
                                                            function($j) {

                                                                $j->setDecodeStatus(array('json.error : ' => $j->getOriginJsonString()),'applyTenderPurchaseAdd.2000','招标采购添加'.'失败');
                                                            }
                                                        )->getDecodeStatus()
												);
        }
}
